-- 脚本参数：KEYS[1..n] 为缓存键，ARGV[1..m] 为座位类型和数量对
local result = {}
local keyIndex = 1
local argIndex = 1

-- 遍历所有缓存键
while keyIndex <= #KEYS do
  local cacheKey = KEYS[keyIndex]
  keyIndex = keyIndex + 1

  -- 获取当前缓存键对应的座位类型数量（每次2个参数：座位类型、数量）
  local count = tonumber(ARGV[argIndex])
  argIndex = argIndex + 1

  -- 处理该缓存键下的所有座位类型
  for i = 1, count do
    local seatType = ARGV[argIndex]
    local num = ARGV[argIndex + 1]
    argIndex = argIndex + 2

    -- 执行哈希表增量操作
    local res = redis.call('HINCRBY', cacheKey, seatType, num)
    table.insert(result, res)
  end
end

return result